package com.gientech.springexercise.controller.redis01;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName ConsumerController
 * @Description TODO
 * @Author zhangfantong
 * @Date 2023/2/16 20:11
 * @Version 1.0
 */
@RestController
public class ConsumerController {
    @Resource
    RedisTemplate redisTemplate;

    String key = "producer01";

    @GetMapping("/consumer")
    public String consumer(){
//        获取key值
        Object value = redisTemplate.opsForValue().get(key);
        if (value == null){
            return "没有东西可消费";
        }
        return "正在消费……>>>>>>>>"+key + "-----"+ value;
    }
}
